import xlrd
from xlutils.copy import copy
def get_excel_data(excelname,sheetName,startRow,endRow,bodyCol=5,expCol=7):
    dataList = [] #定义一个列表，我们需要获得一个列表里面带元组的格式[(),()...]，元组的内容为（请求体，期望值）
    excelDir = '../data/{}'.format(excelname)
    workBook =xlrd.open_workbook(excelDir,formatting_info=True) #获取测试用例对象
    # sheetNames = workBook.sheet_names()
    workSheet =workBook.sheet_by_name(sheetName) #获取测试用例工作页签对象
    for one in range(startRow-1,endRow):
        dataList.append((workSheet.cell(one,bodyCol).value,workSheet.cell(one,expCol).value))
    return dataList
def set_excel_data(setexcel):
    excelDir = '../data/{}'.format(setexcel)
    workBook =xlrd.open_workbook(excelDir,formatting_info=True) #获取测试用例对象
    newWorkBook = copy(workBook) #复制一个新表存入结果，用到了xlutils
    newSheet = newWorkBook.get_sheet(0) #获取新增应用页签
    return newWorkBook,newSheet

#查看excel的页签名称，并打印。ps：xlsx格式的excel会报错，1）改为xls；2）使用openpyxl库

# if __name__ == '__main__':
#     res = get_excel_data('Sheet1',2,2)
#     print(res)

